package com.xxxx.server.controller;


import com.xxxx.server.pojo.*;
import com.xxxx.server.service.IEmployeeRemoveService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhanglishen
 * @since 2020-11-14
 */
@RestController
@RequestMapping("/employee-remove")
public class EmployeeRemoveController {

    @Autowired
    private IEmployeeRemoveService employeeRemoveService;

    @ApiOperation(value = "添加调动记录")
    @PostMapping("/add")
    public RespBean add(@RequestBody EmployeeRemove employeeRemove){
        if (employeeRemoveService.save(employeeRemove)){
            return RespBean.success("调动添加成功");
        }
        return RespBean.error("调动添加失败");
    }

    /**
     * 查询调动记录
     */
    @ApiOperation(value = "查询调动记录")
    @GetMapping("/getList")
    public RespPageBean getTrainList(@RequestParam(defaultValue = "1") Integer currentPage, @RequestParam(defaultValue = "10") Integer size,
                                     EmployeeRemoveBean employeeRemoveBean){
        return employeeRemoveService.getList(currentPage,size,employeeRemoveBean);
    }

    @ApiOperation(value = "删除调动记录")
    @DeleteMapping("/delete/{id}")
    public RespBean delete(@PathVariable Integer id){
        if (employeeRemoveService.removeById(id)){
            return RespBean.success("删除成功");
        }
        return RespBean.error("删除失败");
    }

}
